<?php
/*********************************************
  CPG Dragonfly™ CMS
  ********************************************
  Copyright © 2004 - 2007 by CPG-Nuke Dev Team
  http://dragonflycms.org

  Dragonfly is released under the terms and conditions
  of the GNU GPL version 2 or any later version
**********************************************/
if (!defined('CPG_NUKE')) { exit; }
global $cpgtpl, $DF;

function footmsg()
{
	global $db, $MAIN_CFG;
	$foot = array($MAIN_CFG->global->foot1, $MAIN_CFG->global->foot2, $MAIN_CFG->global->foot3);
	if (CPG_DEBUG || is_admin()) {
		$total_time = (microtime(true) - START_TIME - $db->time);
		$foot[] = sprintf(_PAGEFOOTER, round($total_time,4), $db->num_queries, round($db->time,4));
		// only works if your PHP is compiled with the --enable-memory-limit configuration option
		if (function_exists('memory_get_usage') && START_MEMORY_USAGE > 0) {
			$total_mem = memory_get_usage()-START_MEMORY_USAGE;
			$foot[] = 'Memory Usage: '.(($total_mem >= 1048576) ? round((round($total_mem / 1048576 * 100) / 100), 2).' MB' : (($total_mem >= 1024) ? round((round($total_mem / 1024 * 100) / 100), 2).' KB' : $total_mem.' Bytes'));
		}
		$foot[] = '';
		$DEBUGGER = Dragonfly::getKernel()->DEBUGGER;
		$S_DEBUG_SQL = CPG_DEBUG  || defined('INSTALL') || $MAIN_CFG->debug->database ? Dragonfly_Output_Xhtml::minify($DEBUGGER->get_report('sql')) : false;
		$S_DEBUG_PHP = CPG_DEBUG  || defined('INSTALL') || $MAIN_CFG->debug->error_level ? Dragonfly_Output_Xhtml::minify($DEBUGGER->get_report('php')) : false;
		$S_DEBUG_PER = CPG_DEBUG || DF_MODE_DEVELOPER ? PerformanceLog::stop() : false;
	}
	$GLOBALS['cpgtpl']->assign_var('S_DEBUG_SQL', isset($S_DEBUG_SQL) ? $S_DEBUG_SQL : false);
	$GLOBALS['cpgtpl']->assign_var('S_DEBUG_PHP', isset($S_DEBUG_PHP) ? $S_DEBUG_PHP : false);
	$GLOBALS['cpgtpl']->assign_var('S_DEBUG_PER', isset($S_DEBUG_PER) ? $S_DEBUG_PER : false);
	return Dragonfly_Output_Xhtml::minify('<div style="text-align:center;" class="core_footer">'.implode("<br />\n", $foot).'
	Interactive software released under <a href="http://dragonflycms.org/GNUGPL.html" target="_blank" title="GNU Public License Agreement">GNU GPL</a>,
	<a href="'.URL::index('credits').'">Code Credits</a>,
	<a href="'.URL::index('privacy_policy').'">Privacy Policy</a></div>');
//	$DF->setState(DF::BOOT_DOWN);
}

themefooter();
$cpgtpl->destroy();
//Dragonfly::getKernel()->SESSION->close(); // not needed?
exit;
